﻿$(document).ready(function () {
    var funcStr = "$(\":checkbox\").click(function(){CheckedChildNode(this);});"; eval(funcStr);
});
//function valid() {
//    var ids = "";
//    for (var i = 0; i < $("input:checked").size(); i++)
//    { ids += $("input:checked").eq(i).val() + ","; }
//    if (ids == "") { return confirm("没选中任何信息,是否继续？"); } return true;
//}
function CheckedChildNode(obj) {
    var divs = obj.parentElement.parentElement.parentElement.parentElement.nextSibling;
    if (divs != null && divs.tagName == "DIV") {
        divs = divs.getElementsByTagName("input");
        for (var i = 0; i < divs.length; i++) {
            if (divs[i].type == "checkbox") { divs[i].checked = obj.checked; }
        }
    }
    if (obj.checked) {
        divs = obj.parentElement.parentElement.parentElement.parentElement.parentElement.previousSibling;
        var ips = divs.getElementsByTagName("input");
        for (var i = 0; i < ips.length; i++) {
            if (ips[i].type == "checkbox") { ips[i].checked = obj.checked; } 
        }
        while (divs.parentElement != null) {
            divs = divs.parentElement;
            if (divs != null && divs.tagName == "DIV") {
                divs = divs.previousSibling; var ips = divs.getElementsByTagName("input");
                for (var i = 0; i < ips.length; i++) {
                    if (ips[i].type == "checkbox") { ips[i].checked = obj.checked; }
                }
            }
        }
    }
} 